from django.db import models

# Create your models here.
from core.models import CoreModel
from app.category.models import ArticleCategory

# 文章模型
class Article(CoreModel):
    title = models.CharField(max_length=50, verbose_name="文章标题", help_text="文章标题")
    content = models.TextField(verbose_name="文章内容", help_text="文章内容")
    cover_img = models.ImageField(upload_to="article/", verbose_name="文章封面", default="article/default.jpg")
    cate = models.ForeignKey(
        to=ArticleCategory,
        related_query_name="cate_query",
        null=True,
        verbose_name="文章分类",
        help_text="文章分类",
        on_delete=models.SET_NULL,
        db_constraint=False,
    )
    STATUS_CHOICES = (
        (0, "草稿"),
        (1, "发布"),
    )
    status = models.IntegerField(
        choices=STATUS_CHOICES,
        default=1,
        verbose_name="发布状态",
        null=True,
        blank=True,
        help_text="发布状态",
    )
    
    class Meta:
        db_table = "big_envet_article"
        verbose_name = "文章管理"
        verbose_name_plural = verbose_name
        ordering = ("-id",)
           
    def __str__(self) -> str:
        return self.title